package com.srwl.mytx.domain;


import android.os.Parcel;
import android.os.Parcelable;

import java.util.Date;

public class Task implements Parcelable {
    private String id;

    private String uId;

    private String tId;//悬赏主题 id

    private String title;

    private String employerId;

    private Double amount;

    private Date expiryDate;

    private Integer type;

    private Integer status;

    private Integer employeeDeleteFlag;

    private Integer employerDeleteFlag;

    private Date updated;

    private Date created;

    private Topic targetTopic;//悬赏主题信息

    private User targetUser;//任务领取者信息

    public Task() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId;
    }

    public String gettId() {
        return tId;
    }

    public void settId(String tId) {
        this.tId = tId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getEmployerId() {
        return employerId;
    }

    public void setEmployerId(String employerId) {
        this.employerId = employerId;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Date getExpiryDate() {
        return expiryDate;
    }

    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getEmployeeDeleteFlag() {
        return employeeDeleteFlag;
    }

    public void setEmployeeDeleteFlag(Integer employeeDeleteFlag) {
        this.employeeDeleteFlag = employeeDeleteFlag;
    }

    public Integer getEmployerDeleteFlag() {
        return employerDeleteFlag;
    }

    public void setEmployerDeleteFlag(Integer employerDeleteFlag) {
        this.employerDeleteFlag = employerDeleteFlag;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Topic getTargetTopic() {
        return targetTopic;
    }

    public void setTargetTopic(Topic targetTopic) {
        this.targetTopic = targetTopic;
    }

    public User getTargetUser() {
        return targetUser;
    }

    public void setTargetUser(User targetUser) {
        this.targetUser = targetUser;
    }

    @Override
    public String toString() {
        return "Task{" +
                "id='" + id + '\'' +
                ", uId='" + uId + '\'' +
                ", tId='" + tId + '\'' +
                ", title='" + title + '\'' +
                ", employerId='" + employerId + '\'' +
                ", amount=" + amount +
                ", expiryDate=" + expiryDate +
                ", type=" + type +
                ", status=" + status +
                ", employeeDeleteFlag=" + employeeDeleteFlag +
                ", employerDeleteFlag=" + employerDeleteFlag +
                ", updated=" + updated +
                ", created=" + created +
                ", targetTopic=" + targetTopic +
                ", targetUser=" + targetUser +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.uId);
        dest.writeString(this.tId);
        dest.writeString(this.title);
        dest.writeString(this.employerId);
        dest.writeValue(this.amount);
        dest.writeLong(this.expiryDate != null ? this.expiryDate.getTime() : -1);
        dest.writeValue(this.type);
        dest.writeValue(this.status);
        dest.writeValue(this.employeeDeleteFlag);
        dest.writeValue(this.employerDeleteFlag);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeParcelable(this.targetTopic, flags);
        dest.writeParcelable(this.targetUser, flags);
    }

    protected Task(Parcel in) {
        this.id = in.readString();
        this.uId = in.readString();
        this.tId = in.readString();
        this.title = in.readString();
        this.employerId = in.readString();
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        long tmpExpiryDate = in.readLong();
        this.expiryDate = tmpExpiryDate == -1 ? null : new Date(tmpExpiryDate);
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.employeeDeleteFlag = (Integer) in.readValue(Integer.class.getClassLoader());
        this.employerDeleteFlag = (Integer) in.readValue(Integer.class.getClassLoader());
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        this.targetTopic = in.readParcelable(Topic.class.getClassLoader());
        this.targetUser = in.readParcelable(User.class.getClassLoader());
    }

    public static final Creator<Task> CREATOR = new Creator<Task>() {
        @Override
        public Task createFromParcel(Parcel source) {
            return new Task(source);
        }

        @Override
        public Task[] newArray(int size) {
            return new Task[size];
        }
    };
}
